<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%@ include file="/common/user.jsp"%>
<%
    Integer uid = token.getUid();
	Integer agentId = input.getInt("agent_id", -1);
	String category = "-1";
	if (agentId != -1) {
		List<Map> list = QBuilder.db("basedb").select("new map(id as id, category as category)").from("message_agent").where(new Where("hospital=", hospital).and("status=", STATUS_ENABLE).and("id=", agentId)).query().getResultObj();
		if (!isEmpty(list))
			category = Tools.getDesc(list.get(0).get("category"), "-1");
		else 
			category = "0";
	}
	Where where = new Where("status=", STATUS_ENABLE).and("uid=", uid);
	if (!"-1".equals(category))
		where.and("category in (" + category + ")");
    List<Map> result = QBuilder.db("basedb").select("new map(id as id, title as title, sumary as summary, content as content, category as category, oid as oid,concat(from_unixtime(cTime/1000,'%Y-%m-%d %H:%i:%s'), '') as create_time)").from("Information").where(where).order("cTime", QBuilder.desc).query().getResultObj();
    if (isEmpty(result)) {
        msg = new Message(30041, "暂无消息");
    } else {
		String ids = "-1";
		for (Map map:result) {
			ids  = ids + "," + map.get("id");
		}
		QBuilder.db("basedb").execHQL("update Information set confirm=1 where id in(" + ids + ")");
	}
    msg.put("data", result);
    Tools.encryptPrint(out, msg);
%>
